#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>

namespace DS190718_MaxSubseqSum {
int main();

int MaxSubseqSum4(int A[], int N) {
	int thisSum, maxSum;
	int i = 0;
	thisSum = maxSum = 0;
	for (i = 0; i < N; i++) {
		thisSum += A[i];
		if (thisSum > maxSum)
			maxSum = thisSum;
		else if (thisSum < 0)
			thisSum = 0;
	}
	return maxSum;
}

int main() {
	int A[] = { 4,-3,5,-2,-1,2,6,-2 };
	int maxSum = MaxSubseqSum4(A, sizeof(A) / sizeof(A[0]));
	printf("%d\n", maxSum);
	return 0;
}
}

int main_DS190718_MaxSubseqSum() {
	return DS190718_MaxSubseqSum::main();
}